<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../js/vue.js"></script>
  </head>
  <body>
    <div id="root">
      <div><img :src="img" alt=""></div>
      <button @click="toggle">点我切换图片</button>
    </div>
    <script>
      Vue.config.productionTip = false
      
      new Vue({
        el:"#root",
        data() {
          return {
            img:"../img/1.png"
          }
        },
        methods: {
          toggle(){
            if(this.img=="../img/1.png"){
              this.img="../img/2.png"
            }else{
              this.img="../img/1.png"
            }
          }
        },
      })
      
    </script>
  </body>
</html>
